﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DotaStrategy.Models;

namespace DotaStrategy.Controllers
{
    public class ItemsController : Controller
    {
        MyDotaConnection db = new MyDotaConnection();        
        public ActionResult Index()
        {     
            return View(db.Items);
        }

     

        public ActionResult Details(int id)
        {
            return View(db.Items.Single(i => i.Id == id));
        }

        //
        // GET: /Items/Create

    
        public ActionResult Create()
        {
           return View(new Item());
        } 

        //
        // POST: /Items/Create

        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Create(Item item, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                db.Items.Add(item);
                db.SaveChanges();
                return RedirectToAction("Index", "Items");
            }

            return View(item);
        }

        public ActionResult Mayority(int number) {

            return Json(!(number<2), JsonRequestBehavior.AllowGet);
        
        }
        
    }
}
